<template>
    <div class="w100 p20" style="height: calc(100% - 78px)">
        <check-score class="mb20" :isEdit="isEdit" :record="record"></check-score>
        <Footer
            @save="save"
            @back="back"
            @previousStep="previousStep"
            @nextStep="nextStep"
            :isShowSave="false"
            :isShowSubmit="false"
            :isShowNext="true"
            :isShowPrevious="true"
        ></Footer>
    </div>
</template>

<script>
import mixin from './mixin'
import CheckScore from './CheckScore'
export default {
    mixins: [mixin],
    props: {
        list: {
            type: Array,
        },
        record: {},
        applyNeedData: {},
    },
    components: {
        CheckScore,
    },
    data() {
        return {
            isShowSubmit: false,
            selfEvaluationList: [],
            form: {
                evaluationId: null,
            },
            rules: {
                evaluationId: [
                    {
                        trigger: 'blur',
                        message: '该项未填写',
                        required: true,
                    },
                ],
            },
        }
    },
    mounted() {
        let roleCode = this.$store.state.userInfo?.roleCode
        if (roleCode === 2) {
            this.isShowSubmit = this.record?.cjzt === 2
        }
        if (roleCode > 2) {
            this.isShowSubmit = this.record?.cjzt === 5
        }
        setTimeout(() => {
            this.init()
        }, 1000)
    },
    methods: {
        init() {
            this.form.evaluationId = this.record?.evaluationId
            if (Array.isArray(this.applyNeedData.selfEvaluationList)) {
                this.selfEvaluationList = this.applyNeedData.selfEvaluationList
            }
        },
        async saveApi() {
            this.Bus.$emit('loadingStateChange', true)
            try {
                //type 1保存 type:2  保存并提交
                let params = { evaluationId: this.form.evaluationId, id: this.record?.id, type: 2 }
                let res = await this.applyApi.selfEvaluation(params)
                if (res.code == 200) {
                    this.$message.success(res.message)
                    this.back()
                }
            } catch (e) {
                console.log(e)
            }
            this.Bus.$emit('loadingStateChange', false)
        },
    },
}
</script>

<style lang="scss" scoped></style>
